package com.luom.fsp.controller;

import cn.hutool.json.JSONUtil;
import com.luom.fsp.manager.websocket.WebSocketServer;
import com.luom.fsp.model.NotificationMessage;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("/test")
public class TestController {

    @GetMapping()
    public void hello() throws IOException {
        NotificationMessage message = new NotificationMessage();
        message.setMessageType("order");
        message.setContent("订单编号：11111231132132");
        message.setTimestamp(System.currentTimeMillis());
        WebSocketServer.broadcast(message);
    }

    @PostMapping("/post")
    public void test(@RequestBody NotificationMessage message) {
        message.setTimestamp(System.currentTimeMillis());
        WebSocketServer.broadcast(message);
    }
}
